package io.gitee.vexlife.snake.basic;

import java.util.Random;

import io.gitee.vexlife.snake.GameController;

public class Food {
	private Node pos;

	public Food() {
	}

	public void genFood(GameController gmctrl) {
		if (gmctrl.getWidth() * gmctrl.getHeight() == gmctrl.getSnake().getLength()) {
			gmctrl.gameOver();
			return;
		}
		Random r = new Random();
		pos = gmctrl.getEmptyPositions()[r
				.nextInt(gmctrl.getWidth() * gmctrl.getHeight() - gmctrl.getSnake().getLength())];
	}

	public Node getFoodNode() {
		return this.pos;
	}
}
